<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
          "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="utf-8">
<title>QUnit 'ecdsamod.js' static method test</title>
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="qunit.js"></script>
<link rel="stylesheet" href="qunit.css" type="text/css" media="screen" />

<script src="../ext/cj/cryptojs-312-core-fix.js"></script>
<script src="../ext/cj/x64-core.js"></script>
<script src="../ext/cj/cipher-core_min.js"></script>
<script src="../ext/cj/aes_min.js"></script>
<script src="../ext/cj/tripledes_min.js"></script>
<script src="../ext/cj/enc-base64_min.js"></script>
<script src="../ext/cj/md5_min.js"></script>
<script src="../ext/cj/sha1_min.js"></script>
<script src="../ext/cj/sha256_min.js"></script>
<script src="../ext/cj/sha224_min.js"></script>
<script src="../ext/cj/sha512_min.js"></script>
<script src="../ext/cj/sha384_min.js"></script>
<script src="../ext/cj/ripemd160_min.js"></script>
<script src="../ext/cj/hmac_min.js"></script>
<script src="../ext/cj/pbkdf2_min.js"></script>


<script src="../ext/jsbn.js"></script>
<script src="../ext/jsbn2.js"></script>
<script src="../ext/prng4.js"></script>
<script src="../ext/rng.js"></script>
<script src="../ext/ec.js"></script>
<script src="../ext/ec-patch.js"></script>

<script src="../src/base64x-1.1.js"></script>
<script src="../src/asn1hex-1.1.js"></script>
<script src="../src/asn1-1.0.js"></script>
<script src="../src/crypto-1.1.js"></script>
<script src="../src/ecdsa-modified-1.0.js"></script>
<script src="../src/ecparam-1.0.js"></script>

<script type="text/javascript">
$(document).ready(function(){
var o = KJUR.crypto.ECDSA;

const SIGNATURES = {
  "P-256": [
    {
      "asn1":"3045022100f729843c8bb5f285380ef5e4d708608d7449dadfa50129112668e972d30f210b0220051c589f0ebdad7a41370e9d9ce405734e854788387f21997028312a305ddae8",
      "concat":"f729843c8bb5f285380ef5e4d708608d7449dadfa50129112668e972d30f210b051c589f0ebdad7a41370e9d9ce405734e854788387f21997028312a305ddae8",
      "raw": {"r":"f729843c8bb5f285380ef5e4d708608d7449dadfa50129112668e972d30f210b","s":"051c589f0ebdad7a41370e9d9ce405734e854788387f21997028312a305ddae8"}
    },
    {
      "asn1":"304502205eb5d99ad13adc09bd6df2105c16d7f7565b768e1e9f2e2b8a5e42bcb5f0f083022100b1d8b2091958df331b700c97698c96e2d4c6aebb2cf7b68fc57901b9794582af",
      "concat":"5eb5d99ad13adc09bd6df2105c16d7f7565b768e1e9f2e2b8a5e42bcb5f0f083b1d8b2091958df331b700c97698c96e2d4c6aebb2cf7b68fc57901b9794582af",
      "raw": {"r":"5eb5d99ad13adc09bd6df2105c16d7f7565b768e1e9f2e2b8a5e42bcb5f0f083","s":"b1d8b2091958df331b700c97698c96e2d4c6aebb2cf7b68fc57901b9794582af"}
    },
    {
      "asn1":"3046022100f3ee83e040657dc7228ad28350a512fc48139a5eba421ec8e04c3692d4645cf202210086701829886e409ab81f2388226047453e089090e450e2a9026df52de16dfadf",
      "concat":"f3ee83e040657dc7228ad28350a512fc48139a5eba421ec8e04c3692d4645cf286701829886e409ab81f2388226047453e089090e450e2a9026df52de16dfadf",
      "raw": {"r":"f3ee83e040657dc7228ad28350a512fc48139a5eba421ec8e04c3692d4645cf2","s":"86701829886e409ab81f2388226047453e089090e450e2a9026df52de16dfadf"}
    }
  ],
  "P-384": [
    {
      "asn1":"3064023030ff2c434742949ef193f00a90c9a4bf8dd99f0442d487502b4fdad4dcbfc44e3164479f9c766dab3e4685dfbff46d3502302f4da9694360b868ffc83763123d82ac6d21bb4d7491e63ead157f8b2d2043e2fbcee860dcdcd3b2401f3004352dd05e",
      "concat":"30ff2c434742949ef193f00a90c9a4bf8dd99f0442d487502b4fdad4dcbfc44e3164479f9c766dab3e4685dfbff46d352f4da9694360b868ffc83763123d82ac6d21bb4d7491e63ead157f8b2d2043e2fbcee860dcdcd3b2401f3004352dd05e",
      "raw": {"r":"30ff2c434742949ef193f00a90c9a4bf8dd99f0442d487502b4fdad4dcbfc44e3164479f9c766dab3e4685dfbff46d35","s":"2f4da9694360b868ffc83763123d82ac6d21bb4d7491e63ead157f8b2d2043e2fbcee860dcdcd3b2401f3004352dd05e"}
    },
    {
      "asn1":"3065023042958d6ae304e1acc9414517bc4d90d8d9dea7bb9548a14cc46b86a8614bd3f51737eaf8353a9963856c9d4186e8e46a023100ec025b8368c33facf235541f1f5fcd86049c7f69f9bee67ba905786507e1b016c59aca93ca06535d450c1572d8b4512b",
      "concat":"42958d6ae304e1acc9414517bc4d90d8d9dea7bb9548a14cc46b86a8614bd3f51737eaf8353a9963856c9d4186e8e46aec025b8368c33facf235541f1f5fcd86049c7f69f9bee67ba905786507e1b016c59aca93ca06535d450c1572d8b4512b",
      "raw": {"r":"42958d6ae304e1acc9414517bc4d90d8d9dea7bb9548a14cc46b86a8614bd3f51737eaf8353a9963856c9d4186e8e46a","s":"ec025b8368c33facf235541f1f5fcd86049c7f69f9bee67ba905786507e1b016c59aca93ca06535d450c1572d8b4512b"}
    }
  ],
  "P-521": [
    {
      "asn1":"308186024164f6b34ba7348a7d987257df7969843925b0716c5b96e5bdbb4eb71bf5f5ddcb3f4cbf7ae6aca31e57e931ef68cd15b5bbac892110f6b48c7d436076b9de4245a5024136f0edafb5c6d78e2dd02bf4c233c3f72401c0da68789a0046f6b971d7ef02a638ec351d2d893edc3ac95ee4e003fd22859100ac5cf56267f1ffe599662307e2e5",
      "concat":"64f6b34ba7348a7d987257df7969843925b0716c5b96e5bdbb4eb71bf5f5ddcb3f4cbf7ae6aca31e57e931ef68cd15b5bbac892110f6b48c7d436076b9de4245a536f0edafb5c6d78e2dd02bf4c233c3f72401c0da68789a0046f6b971d7ef02a638ec351d2d893edc3ac95ee4e003fd22859100ac5cf56267f1ffe599662307e2e5",
      "raw": {"r":"64f6b34ba7348a7d987257df7969843925b0716c5b96e5bdbb4eb71bf5f5ddcb3f4cbf7ae6aca31e57e931ef68cd15b5bbac892110f6b48c7d436076b9de4245a5","s":"36f0edafb5c6d78e2dd02bf4c233c3f72401c0da68789a0046f6b971d7ef02a638ec351d2d893edc3ac95ee4e003fd22859100ac5cf56267f1ffe599662307e2e5"}
    },
    {
      "asn1":"308187024103268bca0a5c5fc7b9910efa9f4925d9b1eb411d08bdbf91941c469e4e06fea5b7f6115c67006e836a2f240e057c96d84e10a964e5db87ad281afe59cec1efd609024200fd5d6d9b874fe743cc9cc6ab6b66de667d1c3952e94dffb3d113f8fce92b3f3b419555ed97e54ed038ef091a90242baf84a626d697faf9a169eb75710bdb11b843",
      "concat":"03268bca0a5c5fc7b9910efa9f4925d9b1eb411d08bdbf91941c469e4e06fea5b7f6115c67006e836a2f240e057c96d84e10a964e5db87ad281afe59cec1efd609fd5d6d9b874fe743cc9cc6ab6b66de667d1c3952e94dffb3d113f8fce92b3f3b419555ed97e54ed038ef091a90242baf84a626d697faf9a169eb75710bdb11b843",
      "raw": {"r":"03268bca0a5c5fc7b9910efa9f4925d9b1eb411d08bdbf91941c469e4e06fea5b7f6115c67006e836a2f240e057c96d84e10a964e5db87ad281afe59cec1efd609","s":"fd5d6d9b874fe743cc9cc6ab6b66de667d1c3952e94dffb3d113f8fce92b3f3b419555ed97e54ed038ef091a90242baf84a626d697faf9a169eb75710bdb11b843"}
    },
    {
      "asn1":"308188024201e1a66f447ce86608e717f4a66d1ab046a13964e4269daa790922506e594667feafcd89b372525b3c07a7fefc085bea1f3ff50e10687230b27de4d1179a05781930024200f60de78284181ccf85f8ff32a842866a2d0436b9a4da2702c15d2f97194ecf6d880059ba932e2e347be1002b20fa64d9dd46d05f1b8c4b62163eefc583f9bf153c",
      "concat":"01e1a66f447ce86608e717f4a66d1ab046a13964e4269daa790922506e594667feafcd89b372525b3c07a7fefc085bea1f3ff50e10687230b27de4d1179a0578193000f60de78284181ccf85f8ff32a842866a2d0436b9a4da2702c15d2f97194ecf6d880059ba932e2e347be1002b20fa64d9dd46d05f1b8c4b62163eefc583f9bf153c",
      "raw": {"r":"01e1a66f447ce86608e717f4a66d1ab046a13964e4269daa790922506e594667feafcd89b372525b3c07a7fefc085bea1f3ff50e10687230b27de4d1179a05781930","s":"f60de78284181ccf85f8ff32a842866a2d0436b9a4da2702c15d2f97194ecf6d880059ba932e2e347be1002b20fa64d9dd46d05f1b8c4b62163eefc583f9bf153c"}
    }
  ]
};

for (const curve in SIGNATURES) {
  test(`${curve} asn1SigToConcatSig`, function() {
    for (let i=0; i<SIGNATURES[curve].length; i++) {
      const asn1 = SIGNATURES[curve][i].asn1;
      const concat = SIGNATURES[curve][i].concat;
      equal(o.asn1SigToConcatSig(asn1), concat, `${i+1}`);
    }
  });

  test(`${curve} hexRSSigToASN1Sig`, function() {
    for (let i=0; i<SIGNATURES[curve].length; i++) {
      const asn1 = SIGNATURES[curve][i].asn1;
      const raw = SIGNATURES[curve][i].raw;
      equal(o.hexRSSigToASN1Sig(raw.r, raw.s), asn1, `${i+1}`);
    }
  });

  test(`${curve} concatSigToASN1Sig`, function() {
    for (let i=0; i<SIGNATURES[curve].length; i++) {
      const asn1 = SIGNATURES[curve][i].asn1;
      const concat = SIGNATURES[curve][i].concat;
      equal(o.concatSigToASN1Sig(concat), asn1, `${i+1}`);
    }
  });
}

});
</script>
  
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture">test markup</div>

<b>NOTE:</b>
<p>
Currently this library works for only secp256r1, secp256k1, secp384r1 and secp521 EC curves
besides some other curves are pre-defined.
</p>

<p>
ECC related QUnit test pages: 
<a href="qunit-do-crypto.html">crypto.js</a> | 
<a href="qunit-do-crypto-ecdsa.html">crypto.js Signature class for ECDSA</a> | 
<a href="qunit-do-ecdsamod.html">ecdsa-modified.js</a> | 
<a href="qunit-do-ecparam.html">ecparam.js</a> | 
</p>

</body>
</html>
